﻿using DotPowerJob;
using DotPowerJob.Attributes;
using DotPowerJob.Models;
using DotPowerJob.Responses;

namespace ASPNetCoreExecutor.Jobs
{
    [JobHandler("DemoJobHandler")]
    public class DemoJobHandler : AbstractJobHandler
    {
        private readonly ILogger _logger;
        public DemoJobHandler(ILogger<DemoJobHandler> logger)
        {
            _logger = logger;
        }

        public async override Task<PowerJobResponse> Execute(JobExecuteContext context)
        {
            this._logger.LogInformation("receive demo job handler,parameter:{0}", context.JobParameter);
            this._logger.LogInformation("开始休眠10秒");
            await Task.Delay(10 * 1000);
            this._logger.LogInformation("休眠10秒结束");
            return PowerJobResponse.Successed();
        }
    }
}
